package f.h.dragon.patterns.mediator;

import java.util.Hashtable;
import java.util.Map;

/**
 * AbstractMediator: This class provides a skeletal implementation of the {@link Mediator} interface.
 * 
 * @author Wenlong Meng(wenlong.meng@gmail.com)
 * @version 1.0 at 2012/04/20
 * @since 1.0
 * 
 * @see f.h.dragon.patterns.mediator.Mediator
 */
public abstract class AbstractMediator implements Mediator {

	// local variables
	/**
	 * datas
	 */
	protected Map<String, Colleague> datas = new Hashtable<String, Colleague>();

	//Logic
	/**
	 * add and register c
	 * 
	 * @param c
	 */
	public void add(Colleague c) {
		c.register(this);
		this.datas.put(c.getName(), c);
	}

	/**
	 * remove name
	 * 
	 * @param name
	 */
	public void remove(String name) {
		this.datas.remove(name);
	}

	/**
	 * exec cmd to name
	 * 
	 * @param name
	 * @param cmd
	 * 
	 * @see f.h.dragon.patterns.mediator.Mediator#exec(java.lang.String, java.lang.String)
	 */
	@Override
	public abstract void call(String name, String cmd);
}
